#include "Event.hpp"
#include "Win32Exception.hpp"

#include <windows.h>

namespace EGlib
{
  /////////
  // Event
  Event::Event(bool manual_reset,bool initial_state)
  {
    event_handle = CreateEvent(NULL,manual_reset,initial_state,NULL);
    if(!event_handle)
      throw Win32Exception::get_last_error();
  }

  Event::~Event()
  {
    CloseHandle(event_handle);
  }

  void Event::wait_one()
  {
    WaitForSingleObject(event_handle,INFINITE);
  }

  void Event::set_event()
  {
    SetEvent(event_handle);
  }

  void Event::reset_event()
  {
    ResetEvent(event_handle);
  }
}
